﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace OpenSoftStore.Client.UIL.UserControls
{
    class YhSoftCheckBox : CheckBox
    {
        public YhSoftCheckBox()
        {
            this.KeyUp += new KeyEventHandler(KeyUps);
            this.Enter += new EventHandler(Enters);
            this.Leave += new EventHandler(Leaves);
        }

        private void Enters(object sender, EventArgs e)
        {
            this.BackColor = Color.FromArgb(179, 221, 150);
            //this.OnEnter(e);
        }

        private void Leaves(object sender, EventArgs e)
        {
            this.BackColor = System.Drawing.Color.Transparent;
            //this.OnLeave(e);
        }

        private void KeyUps(object sender, KeyEventArgs e)
        {
            var findForm = FindForm();
            if (findForm == null) return;
            if (e.KeyCode == Keys.Enter)
            {
                findForm.TabIndex = TabIndex + 1;
                findForm.SelectNextControl(this, true, true, true, true);
            }
            if (e.KeyCode == Keys.Add)
            {
                this.Checked = true;
            }
            if (e.KeyCode == Keys.Subtract)
            {
                this.Checked = false;
            }
        }
    }
}
